<!DOCTYPE HTML>
<html lang="en">
	<head>
		<title>three.js canvas - lines - random</title>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
		<style type="text/css">
			body {
				background-color: #000000;
				margin: 0px;
				overflow: hidden;
			}

			a {
				color:#0078ff;
			}
		</style>
        <link rel="stylesheet" type="text/css" href="../style.css"/>
	</head>
<body>

<?php
define('INCLUDE_CHECK',1);
require_once('../connection.php');
require_once('../function.php');

$query=mysql_query("select * from msg order by id desc");
while ($row=mysql_fetch_array($query)) {
	$msgList.=formatSay($row[content],$row[addtime],$row[userid]);
}
?>


<script type="text/javascript" src="../js/Three.js"></script>
<script type="text/javascript" src="../js/RequestAnimationFrame.js"></script>

<script type="text/javascript">

			var mouseX = 0, mouseY = 0,

			windowHalfX = window.innerWidth / 2,
			windowHalfY = window.innerHeight / 2,

			SEPARATION = 200,
			AMOUNTX = 10,
			AMOUNTY = 10,

			camera, scene, renderer;

			init();
			animate();

			function init() {

				var container, separation = 100, amountX = 50, amountY = 50,
				particles, particle;

				container = document.createElement('div');
				document.body.appendChild(container);

				camera = new THREE.Camera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
				camera.position.z = 100;

				scene = new THREE.Scene();

				renderer = new THREE.CanvasRenderer();
				renderer.setSize( window.innerWidth, window.innerHeight );
				container.appendChild( renderer.domElement );

				// particles

				var PI2 = Math.PI * 2;
				var material = new THREE.ParticleCanvasMaterial( {

					color: 0xffffff,
					program: function ( context ) {

						context.beginPath();
						context.arc( 0, 0, 1, 0, PI2, true );
						context.closePath();
						context.fill();

					}

				} );

				var geometry = new THREE.Geometry();

				for ( var i = 0; i < 100; i ++ ) {

					particle = new THREE.Particle( material );
					particle.position.x = Math.random() * 2 - 1;
					particle.position.y = Math.random() * 2 - 1;
					particle.position.z = Math.random() * 2 - 1;
					particle.position.normalize();
					particle.position.multiplyScalar( Math.random() * 10 + 450 );
					particle.scale.x = particle.scale.y = 5;
					scene.addObject( particle );

					geometry.vertices.push( new THREE.Vertex( particle.position ) );

				}

				// lines

				var line = new THREE.Line( geometry, new THREE.LineBasicMaterial( { color: 0xffffff, opacity: 0.5 } ) );
				scene.addObject( line );

				document.addEventListener( 'mousemove', onDocumentMouseMove, false );
				document.addEventListener( 'touchstart', onDocumentTouchStart, false );
				document.addEventListener( 'touchmove', onDocumentTouchMove, false );
			}

			//

			function onDocumentMouseMove(event) {

				mouseX = event.clientX - windowHalfX;
				mouseY = event.clientY - windowHalfY;
			}

			function onDocumentTouchStart( event ) {

				if ( event.touches.length > 1 ) {

					event.preventDefault();

					mouseX = event.touches[ 0 ].pageX - windowHalfX;
					mouseY = event.touches[ 0 ].pageY - windowHalfY;

				}

			}

			function onDocumentTouchMove( event ) {

				if ( event.touches.length == 1 ) {

					event.preventDefault();

					mouseX = event.touches[ 0 ].pageX - windowHalfX;
					mouseY = event.touches[ 0 ].pageY - windowHalfY;

				}

			}

			//

			function animate() {

				requestAnimationFrame( animate );

				render();

			}

			function render() {

				camera.position.x += ( mouseX - camera.position.x ) * .05;
				camera.position.y += ( - mouseY + 200 - camera.position.y ) * .05;

				renderer.render( scene, camera );

			}

		</script>
<div id="header">
   <div id="logo"><h1>
   <a href="#" title="Welcome to Infinity">Infinity</a>
   </h1></div>
</div>

<div id="main">
  <div class="content">
    <form id="txtarea">
      <h3><span class="counter">140</span>Want say something...</h3>
      <textarea name="comment" id="comment" class="input" tabindex="1" rows="5" cols="40"></textarea>
      <p>
      <input type="image" src="../images/btn.gif" class="sub_btn" alt="Push" />
      <span id="msg"></span>
      </p>
    </form>
    <div class="clear"></div>
    <div id="msgwrap">
     <?php echo $msgList;?>
    </div>
  </div>
</div>

<div id="footer">
    <p>Powered by William</p>
</div>
	</body>
</html>
